﻿using MyProxy.Entity;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace MyProxy
{
    class Program
    {
        static void Main(string[] args)
        {
            //int port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
            int port =55500;
            //ip获取
            //string ip = ConfigurationManager.AppSettings["ip"];
            string ip = "127.0.0.1";
            //定义端口号
            TcpListener tcplistener = new TcpListener(IPAddress.Parse(ip), port);
            //Console.WriteLine($"侦听端口：{ip}:{port}");
            tcplistener.Start();
            //侦听端口号
            while (true)
            {
                Socket socket = tcplistener.AcceptSocket();
                IPEndPoint ipPoint = (IPEndPoint)socket.RemoteEndPoint;
                //并获取传送和接收数据的Scoket实例
                Proxy proxy = new Proxy(socket);
                //Proxy类实例化
                Thread thread = new Thread(new ThreadStart(proxy.Run));
                //创建线程
                thread.Start();
                //启动线程
            }
        }
    }
}
